/*
 * StackStatic.c
 *
 *  Created on: 11/11/2011
 *      Author: marcio
 */

#include "Stack.h"

typedef struct nl{
	void* elem;
	struct nl* next;
}NodeStack;

Stack* stack_newStack(){
	Stack* s = malloc(sizeof(Stack));
	s->head = mallaoc(sizeof(NodeStack));
	s->head->next = NULL;
	return s;
}

int stack_add(Stack* s, void* elem){
	NodeStack* newnode = mallaoc(sizeof(NodeStack));
	if(elem != null){
		newnode->elem = elem;
		newnode->next = ((NodeStack*)s->head)->next;
		((NodeStack*)s->head)->next = newnode;
		return 0;
	}
	return 1;
}

void* stack_get(Stack* s){
	return ((NodeStack*)s->head)->elem;
}

void* stack_push(Stack* s){
	NodeStack aux = ((NodeStack*)s->head)->elem;
	((NodeStack*)s->head)->next = ((NodeStack*)s->head)->next->next;
	return aux;
}

int stack_isEmpty(Stack* s){
	return ((NodeStack*)s->head)->next == NULL;
}
